﻿using System;
using CalculatorLib;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CalculatorLib.Test
{
    
    [TestClass]
    public class MathLibTest
    {

        private MathLib _lib;


        [TestInitialize]
        public void SetupLib()
        {
            _lib = new MathLib();
        }

        [TestMethod]
        public void CanSubractNumbers()
        {
            int result = _lib.Subtract(6, 2);
            Assert.AreEqual(4, result);
        }

        [TestMethod]
        public void CanAddNumbers()
        {
            int result = _lib.Add(2, 2);
            Assert.AreEqual(4, result);
        }

        [TestMethod]
        public void CanMultiplyNumbers()
        {
            int result = _lib.Multiply(3, 2);
            Assert.AreEqual(6, result);
        }

        [TestMethod]
        public void CanDivideNumbers()
        {
            float result = _lib.Divide(12, 4);
            Assert.AreEqual(3, result);
        }

        [TestMethod]
        [ExpectedException(typeof(DivideByZeroException))]
        public void DivideByZeroIsThrownWithZeroDivisor()
        {
            _lib.Divide(12, 0);
        }

    }
}
